home *** CD-ROM | disk | FTP | other *** search
/ Die Speccy' 97 / Die Speccy' 97.iso / amiga_system / the_aminet / comm / bbs / wwbbs31_source.lha / WWBBS / RxSrc / abberexx.c next >
C/C++ Source or Header  |  1995-06-20  |  7KB  |  290 lines

  1. #include <exec/types.h>
  2. #include <exec/exec.h>
  3. #include <libraries/wwbbs.h>
  4. #include <ctype.h>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8.  
  9. #include <proto/dos.h>
  10. #include <proto/exec.h>
  11. #include <proto/rexxsyslib.h>
  12. #include <proto/wwbbs.h>
  13.  
  14. #include "rx.h"
  15.  
  16. #include "bbsrx_rev.h"
  17.  
  18. void ABBEREXXCommand(BYTE *id,UWORD cmd,BYTE *arg,char *buff,char **result,char **error,long *errorlevel)
  19.     {
  20.         switch(cmd)
  21.             {
  22.                 case ABBEREXX_BBSIdentify:
  23.                     if(arg)
  24.                         {
  25.                             if(!stricmp(arg,"ABBEREXX"))
  26.                                 *result="1.0";
  27.                             if(!stricmp(arg,"BBS"))
  28.                                 {
  29.                                     sprintf(buff,"%s (%s)",VERS,DATE);
  30.                                     *result=buff;
  31.                                 }
  32.                             if(!stricmp(arg,"EMULATION"))
  33.                                 {
  34.                                     BOOL ansi=FALSE;
  35.                                     GetStatusTags(STTAG_Name,id,STTAG_ANSI,&ansi);
  36.                                     *result=(ansi) ? "ANSI" : "ASCII";
  37.                                 }
  38.                             if(!stricmp(arg,"NAME"))
  39.                                 *result="World Wide BBS";
  40.                             if(!stricmp(arg,"SYSOP"))
  41.                                 {
  42.                                     strcpy(buff,"");
  43.                                     GetUserTags(USRTAG_Name,"Sysop",USRTAG_UserName,buff,TAG_END);
  44.                                     *result=buff;
  45.                                 }
  46.                             if(!stricmp(arg,"TERM"))
  47.                                 {
  48.                                     BYTE baud[11],rows[4],columns[5];
  49.                                     if((GetVar("BAUD",baud,10,NULL)!=-1) && (GetVar("ROWS",rows,3,NULL)!=-1) && (GetVar("COLUMNS",columns,4,NULL)!=-1))
  50.                                         {
  51.                                             sprintf(buff,"%s %s %s 0",baud,rows,columns);
  52.                                             *result=buff;
  53.                                         }
  54.                                 }
  55.                             if(!stricmp(arg,"USER"))
  56.                                 {
  57.                                     BYTE name[33];
  58.                                     strcpy(name,"");
  59.                                     GetStatusTags(STTAG_Name,id,STTAG_UserName,name,TAG_END);
  60.                                     if(strlen(name))
  61.                                         {
  62.                                             UBYTE accesslevel=0;
  63.                                             BYTE *accessname=NULL,city[21],state[21],country[4];
  64.                                             strcpy(city,"");
  65.                                             strcpy(state,"");
  66.                                             strcpy(country,"");
  67.                                             GetUserTags(USRTAG_Name,name,
  68.                                                 USRTAG_AccessLevel,&accesslevel,
  69.                                                 USRTAG_City,city,
  70.                                                 USRTAG_State,state,
  71.                                                 USRTAG_Country,country,
  72.                                                 TAG_END);
  73.                                             if(accesslevel==0)
  74.                                                 accessname="GUEST";
  75.                                             if(accesslevel>0 && accesslevel<255)
  76.                                                 accessname="MEMBER";
  77.                                             if(accesslevel==255)
  78.                                                 accessname="SYSOP";
  79.                                             sprintf(buff,"\"%s\" \"%s, %s  %s\" %s",name,city,state,country,accessname);
  80.                                             *result=buff;
  81.                                         }
  82.                                 }
  83.                         }
  84.                     break;
  85.                 case ABBEREXX_CheckAbort:
  86.                     if(WaitForChar(Input(),0))
  87.                         {
  88.                             int c;
  89.                             c=getchar();
  90.                             if(isspace(c))
  91.                                 *result="1";
  92.                             else
  93.                                 *result="0";
  94.                         }
  95.                     else
  96.                         *result="0";
  97.                     break;
  98.                 case ABBEREXX_CLS:
  99.                     printf("\f");
  100.                     break;
  101.                 case ABBEREXX_GetCarrier:
  102.                     {
  103.                         BOOL local=FALSE;
  104.                         GetStatusTags(STTAG_Name,id,STTAG_Local,&local,TAG_END);
  105.                         if(local || SerialCommandTags(id,SERCMD_Carrier,TAG_END))
  106.                             *result="1";
  107.                         else
  108.                             *result="0";
  109.                     }
  110.                     break;
  111.                 case ABBEREXX_GetChar:
  112.                     {
  113.                         int c;
  114.                         c=getchar();
  115.                         if(c==EOF)
  116.                             *result="###PANIC";
  117.                         else
  118.                             {
  119.                                 sprintf(buff,"%c",c);
  120.                                 *result=buff;
  121.                             }
  122.                     }
  123.                     break;
  124.                 case ABBEREXX_GetUser:
  125.                     if(arg)
  126.                         {
  127.                             switch(atoi(arg))
  128.                                 {
  129.                                     case 1: /* Name */
  130.                                         if(GetStatusTags(STTAG_Name,id,STTAG_UserName,buff,TAG_END)) *result=buff;
  131.                                         break;
  132.                                     case 7: /* Time Remaining */
  133.                                         {
  134.                                             UWORD timeremaining=0;
  135.                                             if(GetStatusTags(STTAG_Name,id,STTAG_TimeRemaining,&timeremaining,TAG_END))
  136.                                                 {
  137.                                                     sprintf(buff,"%d",timeremaining);
  138.                                                     *result=buff;
  139.                                                 }
  140.                                         }
  141.                                         break;
  142.                                     case 15: /* Access group */
  143.                                         *result="0";
  144.                                         break;
  145.                                     case 17: /* System maintenance */
  146.                                         *result="0";
  147.                                         break;
  148.                                     case 18: /* Time used */
  149.                                         {
  150.                                             UWORD timeused=0;
  151.                                             if(GetStatusTags(STTAG_Name,id,STTAG_TimeUsed,&timeused,TAG_END))
  152.                                                 {
  153.                                                     sprintf(buff,"%d",timeused);
  154.                                                     *result=buff;
  155.                                                 }
  156.                                         }
  157.                                         break;
  158.                                     case 19: /* Screen clear code */
  159.                                         *result="\f";
  160.                                         break;
  161.                                     case 23: /* Current port */
  162.                                         *result="0";
  163.                                         break;
  164.                                     case 24: /* CPS */
  165.                                         {
  166.                                             BYTE baud[11];
  167.                                             strcpy(baud,"");
  168.                                             if(GetVar("BAUD",baud,10,NULL)!=-1)
  169.                                                 {
  170.                                                     sprintf(buff,"%ld",atol(baud)/10);
  171.                                                     *result=buff;
  172.                                                 }
  173.                                         }
  174.                                         break;
  175.                                     case 27: /* Current line width */
  176.                                         if(GetVar("ROWS",buff,3,NULL)!=-1)
  177.                                             *result=buff;
  178.                                         break;
  179.                                     case 28: /* Terminal type */
  180.                                         {
  181.                                             BOOL ansi=FALSE;
  182.                                             if(GetStatusTags(STTAG_Name,id,STTAG_ANSI,&ansi,TAG_END))
  183.                                                 *result=(ansi) ? "2" : "0";
  184.                                         }
  185.                                         break;
  186.                                     case 41: /* ID */
  187.                                         strcpy(buff,id);
  188.                                         *result=buff;
  189.                                         break;
  190.                                 }
  191.                         }
  192.                     break;
  193.                 case ABBEREXX_HangUp:
  194.                     SetStatusTags(STTAG_Name,id,STTAG_Panic,TRUE,TAG_END);
  195.                     break;
  196.                 case ABBEREXX_IReady:
  197.                     {
  198.                         BOOL local=FALSE;
  199.                         GetStatusTags(STTAG_Name,id,STTAG_Local,&local,TAG_END);
  200.                         if(local)
  201.                             *result=(ConsoleCommandTags(id,CONCMD_Query,TAG_END)) ? "1" : "0";
  202.                         else
  203.                             *result=(SerialCommandTags(id,SERCMD_Query,TAG_END)) ? "1" : "0";
  204.                     }
  205.                     break;
  206.                 case ABBEREXX_MayGetChar:
  207.                     if(WaitForChar(Input(),0))
  208.                         {
  209.                             int c;
  210.                             c=getchar();
  211.                             sprintf(buff,"%c",c);
  212.                             *result=buff;
  213.                         }
  214.                     break;
  215.                 case ABBEREXX_NewLine:
  216.                     printf("\n");
  217.                     break;
  218.                 case ABBEREXX_Print:
  219.                     if(arg)
  220.                         printf(arg);
  221.                     printf("\n");
  222.                     break;
  223.                 case ABBEREXX_Prompt:
  224.                     if(arg)
  225.                         {
  226.                             char type[256],*s;
  227.                             int length;
  228.                             sscanf(arg,"%d %s",&length,type);
  229.                             if(s=strchr(arg,' '))
  230.                                 {
  231.                                     s++;
  232.                                     if(s=strchr(s,' '))
  233.                                         s++;
  234.                                 }
  235.                             if(length>255)
  236.                                 length=255;
  237.                             printf("~p%s",s);
  238.                             if(!stricmp(type,"NORMAL"))
  239.                                 {
  240.                                     GetLine(buff,length,NULL);
  241.                                     *result=buff;
  242.                                 }
  243.                             if(!stricmp(type,"HIDE"))
  244.                                 {
  245.                                     GetLine(buff,length,GLFLG_NoEcho);
  246.                                     *result=buff;
  247.                                 }
  248.                             if(!stricmp(type,"YESNO"))
  249.                                 *result=(Ask(NULL,TRUE)) ? "Y": "N";
  250.                             if(!stricmp(type,"NOYES"))
  251.                                 *result=(Ask(NULL,FALSE)) ? "Y": "N";
  252.                             printf("~r");
  253.                         }
  254.                     break;
  255.                 case ABBEREXX_Query:
  256.                     if(arg)
  257.                         printf("~p%s",arg);
  258.                     GetLine(buff,255,NULL);
  259.                     *result=buff;
  260.                     break;
  261.                 case ABBEREXX_Receive:
  262.                     GetLine(buff,255,NULL);
  263.                     *result=buff;
  264.                     break;
  265.                 case ABBEREXX_Send:
  266.                     if(arg)
  267.                         printf(arg);
  268.                     break;
  269.                 case ABBEREXX_SendFile:
  270.                     if(arg)
  271.                         ShowText(arg);
  272.                     break;
  273.                 case ABBEREXX_SetNodeLocation:
  274.                     break;
  275.                 case ABBEREXX_SysopLog:
  276.                     if(arg)
  277.                         {
  278.                             BYTE log[33];
  279.                             strcpy(log,"");
  280.                             GetStatusTags(STTAG_Name,id,STTAG_Location,log,TAG_END);
  281.                             if(strlen(log))
  282.                                 {
  283.                                     sprintf(buff,"%.255s",arg);
  284.                                     LogEntry(id,log,buff);
  285.                                 }
  286.                         }
  287.                     break;
  288.             }
  289.     }
  290.